#ifndef __ZUICONTROL_FACTORY_H__
#define __ZUICONTROL_FACTORY_H__

#include "ZUtils.h"
#include "common/ZSharedInstance.h"

namespace ZuiLib
{

class ZControl;

typedef ZControl* (*CreateControlFunc)();

class ZControlFactoryMgr:public ZSharedInstance<ZControlFactoryMgr>
{
public:
	void AddFactory(const char* name,CreateControlFunc func);
	void RemoveFactory(const char* name);
	ZControl* BuildControl(const char* name);
private:
	friend class ZSharedInstance<ZControlFactoryMgr>;
	ZControlFactoryMgr(void);
	~ZControlFactoryMgr(void);
	ZStrHashMap m_map;
};

template<class T>
ZControl* CreateControlFuncImpl()
{
	return new ZRefCountedObject<T>();
}

}//namescpace



#endif